package com.wushi.lenovo.asia5b.app_utils;

import android.app.Activity;
import android.support.annotation.DrawableRes;
import android.support.annotation.StringRes;
import android.view.Gravity;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.mvp.utils.ResString;
import com.wushi.lenovo.asia5b.R;

/**
 * Created by zhangyuncai on 2018/12/14.
 */
public class WToastHelper {
    //自定义带图片的toast
    public static void showContentView(Activity context, @StringRes int contentId) {
        if (context != null) {
            View view = View.inflate(context, R.layout.toast_setpasssuccess, null);
            TextView textView = view.findViewById(R.id.tv_toast_content);
            textView.setText(ResString.get(contentId));
            showSetPassSuccess(context, view);
        }
    }

    public static void showContentView(Activity context, @StringRes int contentId, @DrawableRes int iconId) {
        if (context != null) {
            View view = View.inflate(context, R.layout.toast_setpasssuccess, null);
            TextView textView = view.findViewById(R.id.tv_toast_content);
            ImageView iv_toast_icon = view.findViewById(R.id.iv_toast_icon);
            textView.setText(ResString.get(contentId));
            iv_toast_icon.setImageResource(iconId);
            showSetPassSuccess(context, view);
        }
    }

    //自定义带图片的toast
    public static Toast showSetPassSuccess(Activity context, View view) {

        Toast toast = new Toast(context);
        toast.setGravity(Gravity.CENTER, 0, 0);
        toast.setDuration(Toast.LENGTH_SHORT);
        toast.setView(view);
        toast.show();
        return toast;
    }
}
